package DatingApp;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.TextField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Profile extends MainScreen implements FieldChangeListener{
	
	private ButtonFrames frames;
	private ButtonField msgMe, askOut, viewPics, approveUser, edit, blockUnblock, contacts;
	private BitmapField profilePic;
	//private GridFieldManager body;
	private HorizontalFieldManager body;
	private LabelField nameField, locationField, ethnicityField, religionField, politicalField,
				phoneNumField, bbimField, emailField, ageField, heightField, genderField;
	private String name, gender, location, ethnicity, religion, political, phoneNum, bbim, email;
	private int age;
	private double height;
	
	private TextField biographyField, interestsField;
	private String biography, interests;
	
	private Manager bodyPanel, bodyButtons;
	
	public Profile(){
		this.frames = new ButtonFrames();
		bodyPanel = new VerticalFieldManager();
		bodyButtons = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
		body = new HorizontalFieldManager();
		profilePic = new BitmapField(Bitmap.getBitmapResource("logo_small.png"));
		name = new String("Danoosh");
		biography = new String(
				"My name is Danoosh"
				);
		interests = new String("Hotdogs and Sausages and really gay \n" +
				" things that make me wanna puke oh my gawd.");
		
		this.updateFields();
		this.initializeFields();
		this.createLayout();
	}
	
	/**
	 * Updates profile information.
	 */
	public void updateFields(){
		this.gender = "N/A";
		this.location = "Toronto";
		this.ethnicity = "Gay";
		this.religion = "Bonkers";
		this.political = "No opinion";
		this.phoneNum = "647 222 Saix";
		this.bbim = "7331";
		this.email = "danoosh.15@gmail.com";
		
		this.age = 13;
		this.height = 13.37;
	}
	
	/**
	 * Initialise profile information.
	 */
	private void initializeFields(){
		nameField = new LabelField(name);
		locationField = new LabelField(location);
		ethnicityField = new LabelField(ethnicity); 
		religionField = new LabelField(religion);
		politicalField = new LabelField(political);
		phoneNumField = new LabelField(phoneNum);
		bbimField = new LabelField(bbim);
		emailField = new LabelField(email);
		ageField = new LabelField(age + "");
		heightField = new LabelField(height + "");
		genderField = new LabelField(gender);
		biographyField = new TextField();
		biographyField.setText(biography);
		interestsField = new TextField();
		interestsField.setText(interests);
		
		
		msgMe = new ButtonField("Message");
		askOut = new ButtonField("Ask Out");
		viewPics = new ButtonField("Pictures");
		approveUser = new ButtonField("Approve");
		edit = new ButtonField("Edit");
		blockUnblock = new ButtonField("(Un)Block");
		contacts = new ButtonField("+Contacts");
		
	}
	
	/**
	 * Creates the layout for profile page.
	 */
	private void createLayout() {
		
		setTitle("User Profile");

	
		VerticalFieldManager ll = new VerticalFieldManager();
		VerticalFieldManager lr = new VerticalFieldManager(Manager.FIELD_LEFT);
		Manager left = new HorizontalFieldManager();
		
		bodyPanel.add(profilePic);
		
		
		ll.add(new LabelField("Name:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Age:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Gender:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Location", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Height:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Ethnicity:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Religion:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Political:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Phone:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("Email:", Manager.FIELD_RIGHT));
		ll.add(new LabelField("BBIM:", Manager.FIELD_RIGHT));
		
		lr.add(nameField);
		lr.add(ageField);
		lr.add(genderField);
		lr.add(locationField);
		lr.add(heightField);
		lr.add(ethnicityField);
		lr.add(religionField);
		lr.add(politicalField);
		lr.add(phoneNumField);
		lr.add(emailField);
		lr.add(bbimField);
		

		left.add(ll);
		left.add(lr);
		bodyPanel.add(left);
		bodyPanel.add(biographyField);
		bodyPanel.add(interestsField);
		bodyPanel.add(bodyButtons);

		bodyButtons.add(msgMe);
		bodyButtons.add(askOut);
		bodyButtons.add(viewPics);
		bodyButtons.add(approveUser);
		bodyButtons.add(edit);
		bodyButtons.add(blockUnblock);
		bodyButtons.add(contacts);

		add(frames.getTopFrame());

		body.add(bodyPanel);

		add(body);
		add(frames.getBottomFrame());
	}
	
	/**
	 * 
	 * @param field
	 * @param context
	 */
	public void fieldChanged(Field field, int context) {
		
		// TODO Auto-generated method stub
		
	}

}
